package com.streamer.app

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.widget.Toast

import com.google.android.material.button.MaterialButton
import com.streamer.app.utils.SPUtils
import com.streamer.app.utils.UserManager.saveUserInfo
import com.streamer.app.utils.api.ViewModel
import com.streamer.app.utils.http.Contacts


class HomeActivity : BaseActivity() {
    
    private lateinit var btnStartStream: MaterialButton
    private lateinit var btnThreeScreen: MaterialButton
    private var viewMode = ViewModel()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_home)
        
        initViews()
        setupListeners()
    }
    
    private fun initViews() {
        viewMode.info()
        viewMode.UserInfoLV.observe(this@HomeActivity){
            if(it!=null){
                saveUserInfo(it)
            }
        }
        btnStartStream = findViewById(R.id.btn_start_stream)
        btnThreeScreen = findViewById(R.id.btn_three_screen)
    }
    
    private fun setupListeners() {
        btnStartStream.setOnClickListener {
            // 跳转到直播页面 - 传递参数控制显示开播前状态
            val intent = Intent(this, LiveStreamActivity::class.java)
            intent.putExtra(LiveStreamActivity.EXTRA_LIVE_STATE, LiveStreamActivity.STATE_PRE_LIVE)
            startActivity(intent)
        }
        
        btnThreeScreen.setOnClickListener {
            // 跳转到三分屏直播页面
            val intent = Intent(this, ThreeScreenLiveActivity::class.java)
            startActivity(intent)
        }
    }
    
    // 示例：如何启动直播结束状态
    private fun showLiveEndedScreen() {
        val intent = Intent(this, LiveStreamActivity::class.java)
        intent.putExtra(LiveStreamActivity.EXTRA_LIVE_STATE, LiveStreamActivity.STATE_LIVE_ENDED)
        startActivity(intent)
    }
} 